import request from "../util/request.js";

// import { loginUtil } from "../Service/login.js";

import { getUserId } from "@/Service/huo-qu.js";
async function getUserNameAndPassword() {
    const userPayload = {
        id: parseInt(getUserId()), // ✅ 改为 currentUserId
        username: this.currentUser.username,
        password: this.password
    };

    try {
        const userRes = await request.put('/system/{id}/userBasicInformation', userPayload);

        if (userRes.data.code === 200) {
            // alert('用户名和密码保存成功');
            console.log(userRes.data.username)
            return true;

        } else {
            alert('错误码: ' + userRes.data.code + ' - ' + userRes.data.message);
            return false;
        }
    } catch (error) {
        console.error('保存用户名/密码失败:', error);
        alert('保存用户名/密码失败，请查看控制台日志');
        return false;
    }
}




export { getUserNameAndPassword }